﻿using System;
using System.Collections.Generic;
using System.Text;
using llAma.Backend.Interface;
using socialdeveloperBackend;
using llAma.Interface;

namespace llamaServer
{
    public static class GPC
    {
        
    }
    public static class Backend
    { 
        private static IBackend mBackend;
        private static IGpc mGpc;
        public static IGpc GPC
        {
            get
            {
                if (mGpc == null)
                    mGpc = Implementation.GpcHandler;
                return mGpc;
            }
            set
            {
                if (mGpc != null)
                    throw new InvalidOperationException("The GPC Handler is already set, and cannot be changed.");
                mGpc = value;
            }
        }
        public static void OnNewConnection(IConnection conn)
        {
            Implementation.OnNewConnection(conn);
        }
        public static IBackend Implementation
        {
            get
            {
                if (mBackend == null)
                    mBackend = new SDBackend();
                return mBackend;
            }
            set
            {
                if (mBackend == null)
                    mBackend = value;
                else
                    throw new InvalidOperationException("The backend has already been set and cannot be changed!");
            }
        }
    }
}
